Skip to content

feat: Re.Pack DevTools plugin with agent tools for runtime debugging - #1510

Merged
dannyhw merged 9 commits into
feat/rozenite-tester-appsfrom
feat/repack-devtools-plugin
Nov 18, 2026
Merged

dannyhw merged 9 commits into
feat/rozenite-tester-appsfrom
feat/repack-devtools-plugin

Conversation

@dannyhw

@dannyhw dannyhw commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #1509.

Summary

Adds packages/repack-devtools-plugin (@callstack/repack-devtools-plugin), a private, workspace-only Rozenite plugin. It makes Re.Pack runtime and dev-server state inspectable in DevTools and by fully automated agents. The aim is to reproduce issues and find root causes without a human driving the app.

What it records

  • ScriptManager: every script with normalized locator, status, resolve/load timings, download vs cache, error stage/code/native message, and an event log.
  • Module Federation: v2 instances, remotes, module cache, share scopes with every registered/loaded version, plus MF 2 runtime events through an observe-only runtime plugin. v1 share scopes are read from __webpack_require__.S.
  • Uncaught JS errors (chained to LogBox).
  • Dev server: per-platform compilation status, errors, warnings, assets and changed files, plus a request log that keeps failed response bodies.

Diagnostics (get-overview, severity-sorted, each with a ref to the details):

  • failed or stuck scripts
  • chunk 404s with similarly named emitted assets
  • duplicate singletons
  • requiredVersion mismatches
  • non-semver shared versions (catalog:/workspace:)
  • unreachable remote dev servers
  • failed compilations
  • /symbolicate 400s with the reason

How to reach it

  • 4 DevTools panels: Scripts, Federation, Dev Server, Errors & symbolication.
  • 16 agent tools, rozenite agent callstack/repack-devtools <tool>. Besides reads, they include actions to reproduce issues headlessly: load-script, prefetch-script, invalidate-scripts, load-remote, symbolicate, clear, reload. Typed descriptors are exported from /sdk for @rozenite/agent-sdk.
  • withRepackDevTools(config) adds GET /repack-devtools/state, /compilation?platform= and POST /clear to any dev server, including MF mini-app servers. These work with curl even when the bundle doesn't build.

Tester apps
All four depend on the plugin from the workspace. Everything is behind WITH_ROZENITE=true, as in #1509. tester-federation-v2's host also registers the runtime plugin via runtimePlugins in development.

Agent skills (.agents/skills, symlinked into .claude/skills):

  • repack-debug-runtime: setup, tool and endpoint reference, playbooks per failure type, and gotchas found while testing on device.
  • repack-reproduce-issue: the issue → tester repro → evidence → root cause → fix → regression test loop.

The design doc is in agent_context/repack-devtools-oct2026.

Notes

  • Build: rozenite build emits the CommonJS entry with moduleResolution: node10, which TypeScript 7 removed. scripts/rozenite.mjs runs the CLI with TypeScript 5 (typescript-5 alias) as tsc. The package's own typescript stays at the workspace version. Pinning TS 5 directly gave react-native a different pnpm peer variant, so the MF host bundled two React Native copies and crashed (Tried to register two views with the same name DebuggingOverlay).
  • @swc/helpers devDependency: the testers' SWC loader transforms the linked package's dist (it isn't under node_modules), as with @callstack/repack.
  • Pre-existing issue surfaced: the plugin flags that tester-federation-v2 shares react-native-safe-area-context and react-native-screens with version catalog:testers (copied from package.json). MF logs "does not satisfy the requirement" for these. Not fixed here.

Test plan

  • pnpm --filter @callstack/repack-devtools-plugin test: 38 unit tests covering the ScriptManager reducer, error parsing, stack parsing and symbolication alignment, semver/federation diagnostics, the collector, request diagnostics, the middlewares against a real HTTP server, and the config wrapper.
  • Plugin typecheck, pnpm lint:ci, pnpm build.
  • tester-app pnpm test: 17/17. No new tsc errors in the testers vs. base.
  • Android emulator, tester-app:
    • get-overview reports boot-recorded chunk loads and the /symbolicate 400 from app start.
    • load-script with a bogus chunk produced a RequestFailure record plus a 404 diagnostic pointing at src_asyncChunks_Async_local_tsx.chunk.bundle.
    • symbolicate maps frames correctly. This caught and fixed an off-by-one: Re.Pack's symbolicator drops non-http frames.
  • Android emulator, tester-federation-v2:
    • get-federation shows instances, remotes and share scopes, and the runtime plugin is active.
    • load-remote MiniApp/MiniAppNavigator loads the container and chunks through ScriptManager.
    • With the mini-app server stopped, the overview names the unreachable manifest URL and get-dev-server --origin explains it.
  • Panels render in the Rozenite DevTools UI.
  • iOS not exercised on a device.

@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
repack-website Ready Ready Preview Nov 18, 2026 2:12pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d69be5d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dannyhw
dannyhw added this pull request to stack #1511 October 22, 2026 13:24
@MrMuzyk

MrMuzyk commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

/review

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 6 new findings on b73f502. The verdict and the full list are in the summary comment.

@MrMuzyk MrMuzyk left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dannyhw Left a few comments :) Needs a rebase for sure too.

Something that we discussed about but is out of scope here is exploring the idea of recreating this federation plugin as a baseline plugin for Rozenite

Add a private, workspace-only Rozenite plugin (packages/repack-devtools-plugin)
that records ScriptManager activity, Module Federation runtime state and
events, uncaught errors, dev-server compilations and requests, and turns them
into diagnostics.

- Panels for scripts, federation, dev server and errors/symbolication
- 16 `rozenite agent callstack/repack-devtools` tools, including actions to
  reproduce issues headlessly (load-script, load-remote, invalidate-scripts,
  symbolicate, reload)
- `withRepackDevTools` adds a compilation collector and
  `/repack-devtools/state` endpoints to any Re.Pack dev server
- MF 2 runtime plugin export for recording from container start-up

Wire it into all tester apps behind WITH_ROZENITE=true and add the
repack-debug-runtime and repack-reproduce-issue skills describing how to use
it to reproduce and root-cause issues.
…ults

Add agent tools to check retry, dedup and cache behaviour and to test
failure handling without changing app code:

- list-script-calls: every loadScript/prefetchScript/invalidateScripts
  call with outcome, duration, whether resolvers ran and whether it
  reused a stored attempt (the #1506 signature). The tracer returns a
  derived promise so unhandled rejections are still reported.
- get-script-manager: stored promises with their state, resolvers,
  hook taps and cache; flags stored rejected promises.
- inject-script-fault: fail or delay the resolve/load stage through
  ScriptManager hooks.
- inject-server-fault / list-faults / clear-faults: make any dev server
  wrapped with withRepackDevTools (MF remotes included) answer with an
  error status, a delay or a dropped connection; also available as
  GET|POST|DELETE /repack-devtools/faults.

The request log now records connections closed before a response
(status 0) and marks faulted responses. The MF runtime plugin records
the manifest HTTP status, since MF parses error pages as JSON and only
reports a parse error.
…nostics

Panels:
- Detail boxes no longer collapse over the next section and scroll
  into view when opened from a table row.
- Table cells keep long ids, URLs and messages on one line (full value
  on hover) instead of breaking every few characters; times, sizes and
  durations do not wrap; tables scroll sideways in narrow panels
  instead of clipping columns.
- Diagnostics show identical messages once and only the first three
  until expanded.
- Dev server: requests come before build output, warnings/errors and
  assets are collapsible, platforms that were never built show
  "not requested".
- The symbolication result scrolls into view; the federation load box
  is hidden without an MF runtime.

Data:
- Strip ANSI colour codes from /symbolicate code frames.
- Report a shared-package problem once when instances share a scope.
- Group MF load failures per URL and downgrade them to warnings when a
  later load of the same URL succeeded.
…build on Node < 20.19

The tester apps now load the plugin from their gated rozenitePlugins.ts and
import the bundler entry dynamically, including the MF mini-app configs, so
default dev runs and E2E builds never load it.

Rozenite and Vite 7 need Node 20.19+, and tester-app's tests depend on this
package's build through turbo, which broke the Node 18 test matrix. The build
now skips on older Node; nothing loads the package without WITH_ROZENITE and
its tests run from source.
- Read MF share flags written as numbers (Rspack emits `singleton: 1`,
  `eager: 1`), so duplicate-singleton and strictVersion diagnostics fire.
- satisfiesRange returns undefined for wildcards, partial versions and
  prereleases instead of treating `1.x` as an exact `1.0.0`.
- Forward compilations from Re.Pack's webpack worker threads to the dev
  server's store over a BroadcastChannel; /repack-devtools/state was empty
  with webpack.
- get-overview also queries the dev servers of MF remotes and other script
  origins and merges their diagnostics, prefixed with the origin.
- Drop `Access-Control-Allow-Origin: *` and refuse cross-origin POST/DELETE
  to /repack-devtools/*, so a web page cannot inject faults.
- load-remote reports a missing instance name and a default instance
  without loadRemote separately.
- Dev-server panel shows a first in-flight build as compiling, and the
  errors panel shows symbolication failures instead of dropping them.
…in the webpack host config

Matches the Rspack host config, so startup MF events are recorded with USE_WEBPACK too.
…ck-reproduce-issue

Covers tester-federation-v2's NativeWind/Reanimated/E2E coverage, tester-expo-widget, and jest, vitest and @e2e-dev/mobile test layers.
@dannyhw

dannyhw commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto the updated #1509 / main, and the review comments are addressed in fcb9dd2, 67e066e and be30b3b (replies are on each thread). Plugin tests 71/71, typecheck and lint pass. I checked the webpack worker forwarding and the cross-origin guard live against a webpack dev server.

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 2 new findings on be30b3b. The verdict and the full list are in the summary comment.

…t-overview, boot-record tester-expo

get-overview probed every script origin as a dev server, so a chunk loaded
from a CDN was listed as an unreachable dev server on every call. MF remote
origins are still always reported; other script origins are reported only
when they serve DevTools state, origins that answer without it are not
probed again, and remote probes time out after 3 s.

tester-expo never called installRepackDevTools({ boot: true }), so its
overview always warned that startup events may be missing. The root layout
module now starts recording, since expo-router/entry is the app entry.
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of d69be5d

Since the review of be30b3b: 0 new · 0 still open · 2 no longer raised (2 marked fixed)

No open findings.

Not in the reviewers' prompt (13 files)
  • .agents/skills/repack-debug-runtime/SKILL.md: left out as an asset or for its size; reviewers could still search it
  • .agents/skills/repack-reproduce-issue/SKILL.md: left out as an asset or for its size; reviewers could still search it
  • .gitignore: left out as an asset or for its size; reviewers could still search it
  • agent_context/repack-devtools-oct2026/design.md: left out as an asset or for its size; reviewers could still search it
  • apps/tester-app/package.json: left out as an asset or for its size; reviewers could still search it
  • apps/tester-expo/package.json: left out as an asset or for its size; reviewers could still search it
  • apps/tester-federation-v2/package.json: left out as an asset or for its size; reviewers could still search it
  • apps/tester-federation/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/repack-devtools-plugin/package.json: left out as an asset or for its size; reviewers could still search it
  • packages/repack-devtools-plugin/tsconfig.bundler.json: left out as an asset or for its size; reviewers could still search it
  • packages/repack-devtools-plugin/tsconfig.json: left out as an asset or for its size; reviewers could still search it
  • pnpm-lock.yaml: generated or a lockfile, so its lines were left out
  • pnpm-workspace.yaml: left out as an asset or for its size; reviewers could still search it

6 findings below minor hidden (user_settings.min_severity).

1 new finding away from what changed since be30b3b not shown. Comment @apex-sentinel-staging review for a full review.

Reviewed with this repository's own Sentinel configuration (6e72ac0df314).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@dannyhw
dannyhw merged commit b9f19df into main Nov 18, 2026
13 checks passed
@dannyhw
dannyhw deleted the feat/repack-devtools-plugin branch November 18, 2026 14:36

This branch was successfully deployed

1 active deployment
Preview — d69be5d9 Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants